<?php

class Application_Model_DbTable_Interestinfo extends Zend_Db_Table_Abstract
{

    protected $_name = 'InterestInfo';
    protected $_primary = 'id';

	public function getInterestInfo($userID)
    {
    	$userID = (int)$userID;
    	$row = $this->fetchRow("User_id = " . $userID);
    	if (!$row) {
			return null;
		}
    	return $row->toArray();
    }
    
    public function existsInterestInfo($userID)
    {
    	$userID = (int)$userID;
    	$row = $this->fetchRow('User_id = ' . $userID);
    	
    	if(!$row)
    	{
    		return '0';
    	}
    	else return '1';
    }
    
    public function createInterestInfo($userID, $visible)
    {
    	$data = array(
    		'Work' => "",
    		'Music' => "",
    		'ViewPermitions' => $visible,
    		'User_id' => $userID,
    	);
    	$this->insert($data);
    }

    public function editInterestsInfo($sportsInfoId, $work, $music, $visible)
    {
    	$data = array(
    		'Work' => $work,
    		'Music' => $music,
    		'ViewPermitions' => $visible,
    	);
    	$this->update($data, 'id = '. (int)$sportsInfoId);
    }
    

}

